<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>狭义闭包</h2>
</body>
<script>
    function closure() {
        let i=1;
        return function() {
            i++;
            return i;
        }
    }

    const fn=closure()
    console.log(i)   
    console.log(fn()) 
    console.log(fn())
    console.log(fn())
    fn=null
    const fn2=closure()
    console.log(fn2())
    fn2=null
</script>
</html>